import request from '@/utils/request'

export function install(data) {
  return request({
    url: 'api/bizAgent/install',
    method: 'post',
    data
  })
}

export function start(data) {
  return request({
    url: 'api/bizAgent/start',
    method: 'post',
    data: data
  })
}

export function stop(data) {
  return request({
    url: 'api/bizAgent/stop',
    method: 'post',
    data: data
  })
}

export function restart(data) {
  return request({
    url: 'api/bizAgent/restart',
    method: 'post',
    data: data
  })
}

export function upgrade(data) {
  return request({
    url: 'api/bizAgent/upgrade',
    method: 'post',
    data: data
  })
}

export function saveAndInstall(data) {
  return request({
    url: 'api/bizAgent/saveAndInstall',
    method: 'post',
    data
  })
}

export function getLogFileList(data) {
  return request({
    url: 'api/bizAgent/getLogFileList',
    method: 'post',
    data
  })
}

export function getLogFileInfo(data) {
  return request({
    url: 'api/bizAgent/getLogFileInfo',
    method: 'post',
    data
  })
}

export function getStatus(data) {
  return request({
    url: 'api/bizAgent/getStatus',
    method: 'post',
    data
  })
}

export function downLogFile(data) {
  return request({
    url: 'api/bizAgent/downLogFile?appType=' + data.appType + '&agentHost=' + data.agentHost + '&agentPort=' + data.agentPort +
        '&agentCode=' + data.agentCode + '&agentName=' + data.agentName + '&version=' + data.version + '&logFilePath=' + data.logPath,
    method: 'get',
    responseType: 'blob'
  })
}

export default { install, start, stop, restart, saveAndInstall, upgrade, getLogFileList, getLogFileInfo, downLogFile, getStatus }
